package com.ld.security.demo.event;

import com.ld.security.server.blog.modules.cms.entity.CmsCollectEntity;
import com.ld.security.server.blog.modules.cms.entity.CmsContentEntity;
import com.ld.security.server.blog.modules.cms.vo.CollectDetailsVo;
import com.ld.security.server.blog.modules.cms.web.CmsDetailsEvent;
import com.ld.security.server.user.modules.ups.entity.UpsActionEntity;
import com.ld.security.server.user.modules.ups.util.UpsUtil;
import org.springframework.stereotype.Component;

@Component
public class CmsDetailsEventImpl implements CmsDetailsEvent {

    @Override
    public void getContentDetais(CmsContentEntity vo) {
        UpsActionEntity ups =   new UpsActionEntity();
        ups.setContentType( vo.getLabelMap().get("cmsType").toString());
        ups.setContent(vo.getDigest());
        ups.setLabel(vo.getLabel());
        ups.setContentCrtUser(vo.getAuthorId());
        ups.setContentId(vo.getId());
        ups.setActionType("内容详情");
        UpsUtil.saveAction(ups);
    }

    @Override
    public void getCollectDetails(CollectDetailsVo vo) {
        CmsCollectEntity val =  vo.getCollect();

        UpsActionEntity ups =   new UpsActionEntity();
        ups.setContentType( val.getLabelMap().get("cmsType").toString());
        ups.setContent(val.getDigest());
        ups.setLabel(val.getLabel());
        ups.setContentCrtUser(val.getAuthorId());
        ups.setActionType("专辑详情");
        ups.setContentId(val.getId());
        UpsUtil.saveAction(ups);
    }
}
